/**
 * 
 */
package cc.dogtailflower.framework.bean;

import cc.dogtailflower.framework.constant.RequestMethod;

/**
 * Controller类中@RequestMapping方法中的 请求路径和方法的封装
 * @author cc
 *
 */
public class Request {

	/*
	 * 请求方法
	 */
	private RequestMethod requestMethod;
	
	/*
	 * 请求路径
	 */
	private String requestPath;

	public Request(RequestMethod requestMethod, String requestPath) {
		super();
		this.requestMethod = requestMethod;
		this.requestPath = requestPath;
	}

	public RequestMethod getRequestMethod() {
		return requestMethod;
	}

	public String getRequestPath() {
		return requestPath;
	}
	
	/*
	 * 重写这两个方法，用于Map key的想等性判断
	 */
	@Override
	public int hashCode(){
		return this.requestMethod.hashCode() + this.requestPath.hashCode();
	}
	
	@Override
	public boolean equals(Object obj){
		if(!(obj instanceof Request)){  
            return false;  
        }  
     
		Request request =(Request)obj;  
		return request.requestMethod.toString().equals(this.requestMethod.toString()) && request.requestPath.equals(this.requestPath);
	}
	
	
}
